<template>
	<view style="height: 100%;">
		<userinfo id="user" :options="user_options" @getUserscope="getUserInfo" @toLogin="getUserInfo"></userinfo>

		<view class="wrapper">
			<!-- 发起拼单 -->
			<view class="header-box" :style="'background:#' + shopBackgroundColor + ';'" v-if="isShare == 0">
				<button hover-class="btn-hover" @tap="openMask" :style="'color:' + mobile_head_color + ';'">
					<text class="iconfont icon-jia1"></text>
					<lang class="desc" keywords="添加订购人"></lang>
				</button>

				<view>
					<view class="tip-box">
						<text class="iconfont icon-tishi"></text>
						<lang keywords="如需商家分开打包或邀请好友多人点单请点击添加订购人；如果正在操作时返回上一页，则已选数据会被清空。"></lang>
					</view>

					<view class="tip-box" hidden="true">
						<lang keywords="商家可按订餐人分开打包"></lang>
					</view>
				</view>
			</view>

			<!-- 拼单被邀请 -->
			<view class="header-box" :style="'background:#' + shopBackgroundColor + ';'" v-if="isShare == 1 && cartInfo">
				<image  :src="cartInfo.store.images" mode="aspectfit"></image>
				<view class="name" >{{cartInfo.store.name}}</view>
				<view class="text" v-if="cartInfo.status == 0">
					<lang keywords="发起人 X1 邀请您一起点单" :X1="master"></lang>
				</view>
				<view class="text" v-if="cartInfo.status == 1">
					<lang keywords="发起人 X1 已锁单，正在支付" :X1="master"></lang>
				</view>
				<view class="text" v-if="cartInfo.status == 2">
					<lang keywords="发起人 X1 付款成功, 等待商家接单" :X1="master"></lang>
				</view>

				<view class="text" v-if="cartInfo.status == 3">
					<lang keywords="发起人 X1 付款成功，商家配送中" :X1="master"></lang>
				</view>
				<view class="text" v-if="cartInfo.status == 4">
					<lang keywords="此次拼单已完成"></lang>
				</view>
				<view class="text" v-if="cartInfo.order.status == 5">
					<lang keywords="此次拼单已退款"></lang>
				</view>
				<view class="text" v-if="cartInfo.status == 6">
					<lang keywords="发起人 X1 已取消订单" :X1="master"></lang>
				</view>
				<button :style="'color:' + mobile_head_color + ';'" hover-class="btn-hover" @tap="selectGoods" v-if="cartInfo.myData == '' && cartInfo.status == 0">
					<lang class="desc" keywords="选购商品"></lang>
				</button>
			</view>

			<view class="null-box" v-if="cartInfo == '' || (cartInfo.data.length == 0 && cartInfo.myData == '')">
				<image :src="requestDomain + 'static/new_shop/sn_null.png'" mode="widthFix"></image>
				<view>
					<lang keywords="还没有订餐人，赶紧去添加吧"></lang>
				</view>
			</view>

			<view class="list-box" v-if="cartInfo && (cartInfo.data.length > 0 || cartInfo.myData)">
				<view class="cancel-mask" v-if="isShare == 1 && cartInfo.status == 6"></view>

				<view class="my" v-if="isShare == 1 && cartInfo && cartInfo.myData != ''">
					<view class="item border-b">
						<view class="user-box">
							<view class="name-box">
								<text :style="'background:' + mobile_head_color + ';'" v-if="cartInfo.myData.avatar == ''" class="num">{{cartInfo.myData.index}}</text>
								<image v-if="cartInfo.myData.avatar != ''" class="avatar" :src="cartInfo.myData.avatar"></image>
								<text class="name">{{cartInfo.myData.name}}</text>
								<text class="iconfont icon-bianji" hidden="true"></text>
								<block v-if="isShare == 0 && cartInfo.myData.avatar != ''">
									<lang class="tag weixin" keywords="微信"></lang>
								</block>
								<block v-if="cartInfo.myData.index == 1">
									<lang class="tag launch" keywords="发起"></lang>
								</block>
								<block v-if="isShare == 0 && cartInfo.myData.index == personId">
									<lang class="tag my" keywords="我"></lang>
								</block>
							</view>
							<view class="edit-box" v-if="cartInfo.order.status == 0">
								<view class="block-in" v-if="isShare == 1 && cartInfo.myData.data.length == 0" @tap="changeGoods(cartInfo.myData.index)">
									<lang class="btn" :style="'border-color:' + mobile_head_color + ';color:' + mobile_head_color + ';'" keywords="添加商品"></lang>
								</view>
								<view class="block-in" @tap="changeGoods(cartInfo.myData.index)" v-if="cartInfo.myData.data.length > 0">
									<lang class="btn" :style="'border-color:' + mobile_head_color + ';color:' + mobile_head_color + ';'" keywords="修改商品"></lang>
								</view>
								<view class="block-in" v-if="cartInfo.myData.data.length > 0" @tap="deleteGoods($event)" :data-id="cartInfo.myData.index">
									<lang class="del" keywords="不订了"></lang>
								</view>
							</view>
						</view>

						<view class="goods-box">
							<view class="one" v-for="(goods, index) in cartInfo.myData.data" :key="goods.productId">
								<view class="name">
									<view>{{goods.productName}}</view>
									<view class="desc" v-if="goods.spec">{{goods.spec}}</view>
								</view>

								<text class="num">x{{goods.count}}</text>
								<view class="price">
									<view class="old block-in" v-if="goods.oldPrice != goods.productPrice">
										{{currency + goods.oldPrice}}
									</view>
									{{currency + goods.productPrice}}
								</view>
							</view>
							<view style="color: #666;font-size:14px;" :hidden="cartInfo.myData.data.length > 0">
								<lang keywords="还没有添加商品"></lang>
							</view>
						</view>
					</view>
				</view>

				<view class="title-box border-t">
					<text class="iconfont icon-dingdan"></text>
					<lang keywords="拼单列表"></lang>
				</view>

				<view class="border-t">
					<view class="item border-b" v-for="(item, index) in cartInfo.data" :key="item.name">
						<view class="user-box">
							<view class="name-box">
								<text :style="'background:' + mobile_head_color + ';'" v-if="item.avatar == ''" class="num">{{item.index}}</text>
								<image v-if="item.avatar != ''" class="avatar" :src="item.avatar"></image>
								<text class="name">{{item.name}}</text>
								<text class="iconfont icon-bianji" hidden="true"></text>
								<block v-if="isShare == 0 && item.avatar != ''">
									<lang class="tag weixin" keywords="微信"></lang>
								</block>
								<block v-if="item.index == 1">
									<lang class="tag launch" keywords="发起"></lang>
								</block>
								<block v-if="isShare == 0 && item.index == personId">
									<lang class="tag my" keywords="我"></lang>
								</block>
							</view>
							<view class="edit-box" v-if="cartInfo.order.status == 0">
								<view class="block-in" v-if="isShare == 0 && item.data.length == 0" @tap="changeGoods(item.index)">
									<lang class="btn" :style="'border-color:' + mobile_head_color + ';color:' + mobile_head_color + ';'" keywords="添加商品"></lang>
								</view>
								<view class="block-in" @tap="changeGoods(item.index)" v-if="(isShare == 0 && item.data.length > 0 && item.avatar == '') || (isShare ==  1 && item.name == userInfo.nickname)">
									<lang class="btn" :style="'border-color:' + mobile_head_color + ';color:' + mobile_head_color + ';'" keywords="修改商品"></lang>
								</view>
								<view class="block-in" v-if="isShare == 0 && item.index != 1" @tap="deleteGoods($event)" :data-id="item.index">
									<lang class="del" keywords="删除"></lang>
								</view>
								<view class="block-in" v-if="isShare == 1 && cartInfo.myData == ''" @tap="selectSame(index)">
									<lang class="del" keywords="和ta点一样"></lang>
								</view>
							</view>
						</view>

						<view class="goods-box">
							<view class="one" v-for="goods in item.data" :key="goods.productId">
								<view class="name">
									<view>{{goods.productName}}</view>
									<view class="desc" v-if="goods.spec">{{goods.spec}}</view>
								</view>

								<text class="num">x{{goods.count}}</text>
								<view class="price">
									<view class="old block-in" v-if="goods.oldPrice != goods.productPrice">
										{{currency + goods.oldPrice}}
									</view>
									{{currency + goods.productPrice}}
								</view>
							</view>
							<view style="color: #666;font-size:14px;" :hidden="item.data.length > 0">
								<lang keywords="还没有添加商品"></lang>
							</view>
						</view>
					</view>

				</view>
 
				<view class="item" v-if="isShare == 1 && cartInfo.myTotalPack > 0">
					<view class="user-box package">
						<view class="name-box">
							<lang class="name" keywords="我的费用"></lang>
						</view>
					</view>
					<view class="goods-box">
						<view class="one">
							<lang class="name" keywords="打包费"></lang>
							<view class="price block-in" >
								{{currency + cartInfo.myTotalPack}}
							</view>
						</view>
					</view>
				</view>

				<view class="item" v-if="isShare == 0 && cartInfo.totalPack > 0">
					<view class="user-box package">
						<view class="name-box">
							<lang class="name" keywords="其他费用"></lang>
						</view>
					</view>
					<view class="goods-box">
						<view class="one">
							<lang class="name" keywords="打包费"></lang>
							<view class="price block-in">
								{{currency + cartInfo.totalPack}}
							</view>
						</view>
					</view>
				</view>

				<view class="footer" v-if="isShare == 0">
					<button class="price">
						{{currency + total_money}}
					</button>
					<button class="cancel" hover-class="cancel-hover" @tap="cancel">
						<lang keywords="取消拼单"></lang>
					</button>
					<button class="calc" :style="'background:' + mobile_head_color" hover-class="none" @tap="gotocalculate">
						<lang keywords="去结算"></lang>
					</button>
				</view>

				<view class="footer other" v-if="isShare == 1 && cartInfo.myTotalPrice > 0 || cartInfo.myTotalPack > 0">
					<view :style="'text-align:right;color:' + ( cartInfo.status == 6 ? '#ddd' : '#333') + ';'">
						<lang keywords="我一共消费"></lang>：<view class="fee block-in" :style="'color:' + mobile_head_color">
							{{currency + (cartInfo.myTotalPrice + cartInfo.myTotalPack) }}
						</view>
						<block v-if="cartInfo.status == 0">
							<lang keywords="(发起人还未支付)"></lang>
						</block>
						<block v-if="cartInfo.status == 2">
							<lang keywords="(发起人已付款)"></lang>
						</block>
						<block v-if="cartInfo.status == 5">
							<lang keywords="(已退款)"></lang>
						</block>
						<block v-if="cartInfo.status == 6">
							<lang keywords="(发起人已取消)"></lang>
						</block>
					</view>
				</view>


			</view>
		</view>

		<view class="mask" :hidden="!showMask" @tap="closeMask($event)" data-name='showMask'>
			<view class="content">
				<view class="option" @tap="addNewOrder">
					<view class="icon">
						<text class="iconfont icon-dabao"></text>
					</view>
					<view>
						<view>
							<lang keywords="分袋打包"></lang>
						</view>
						<view class="desc">
							<lang keywords="让商家分开打包商品"></lang>
						</view>
					</view>
				</view>

				<button class="option border-t" open-type="share" @tap="shareToFriend">
					<view class="icon weixin">
						<text class="iconfont icon-weixin"></text>
					</view>
					<view>
						<view>
							<lang keywords="邀请微信好友点餐"></lang>
						</view>
						<view class="desc">
							<lang keywords="发送微信链接，邀请好友一起点餐"></lang>
						</view>
					</view>
				</button>
			</view>
		</view>

		<!-- #ifdef H5 -->
		<view class="mask" v-if="showShareTip" @tap="closeMask($event)" data-name='showShareTip'>
			<image class="share-img" :src="requestDomain + 'tpl/Wap/pure/static/images/guide1.png'" mode=""></image>
		</view>
		<!-- #endif -->

		<view class="mask" v-if="isShare == 1 && cartInfo.status == 1">
			<view class="content locking">
				<view class="title">
					<lang keywords="提示"></lang>
				</view>
				<view class="desc">
					<lang keywords="订单锁定中，如需继续点单请联系订单发起人解锁订单！"></lang>
				</view>
			</view>
		</view>


	</view>
</template>



<script>
	// 拼单页面
	import common from '../../../utils/common.js';
	import shopCommon from '../../../utils/shop/addToCart.js'
	var app = getApp();
	var _this;
	var shareTxt = '有人一起拼单吗？';

	export default {
		data() {
			return {
				
				productCart: [], //购物车数据
				cartInfo: '', // 购物车数据
				refresh: false,
				goosInfo: '', // 购物车商品信息
				showMask: false,
				cancelStatus: false, // 是否取消拼单
				isSelected: false, // 是否点击了选购商品的按钮
				showAuthBtn: false, // 是否显示授权登录窗口
				options: {},
				total_money: 0, // 总计金额
				mobile_head_color: '',
				requestDomain: common.requestDomain,
				showShareTip: false,
				
				master: '', // 发起人的nickname
				userInfo: '', // 当前用户信息
				shopFrontColor: 'ffffff',
				shopBackgroundColor: '113533',
				store_id: '', // 店铺id
				user_options: {},
				storeInfo: '',
				currency: '¥',
				isShare: 0, // 0正常打开  1分享链接打开
				cartId: '', // 购物车id
				personId: '', // 拼单人id
				timer: '', // 每隔5秒请求一次购物车数据
				isShowLock: false
			};
		},
		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad(options) {
			_this = this;
			_this.store_id = options.store_id
			_this.options = options
			common.getConfig(function(config){
				_this.mobile_head_color = config.config.mobile_head_color
				_this.currency = config.config.Currency_symbol
			})
			
			wx.setNavigationBarTitle({
				title: common.changeTxt('多人点单')
			});
			shareTxt = common.changeTxt(shareTxt);
			
			if (options.nickname) {
				_this.isShare = 1
				_this.master = options.nickname
				_this.cartId = options.cartId
				_this.personId = 1
			}
			
			if (app.globalData.is_login) {
				common.getUser(() => {
					_this.userInfo = app.globalData.userInfo
					if (!_this.master) {
						_this.master = app.globalData.userInfo.nickname
					} else if (_this.master == app.globalData.userInfo.nickname && _this.isShare == 1) {
						_this.isShare = 0
						let orderTogether = {
							store_id: _this.store_id,
							cartId: _this.cartId,
							myindex: data.index
						}
						uni.setStorageSync('orderTogether', orderTogether)
					}
					initialCart()	
					if (app.globalData.storeInfo) {
						_this.storeInfo = app.globalData.storeInfo
						_this.shopFrontColor = _this.storeInfo.shop_fitment_front_color
						_this.shopBackgroundColor = _this.storeInfo.shop_fitment_color 
						wx.setNavigationBarColor({
							frontColor: "#" + _this.shopFrontColor,
							backgroundColor: '#' + _this.shopBackgroundColor
						});
						_this.setWxShare()
					}
				})
			} else {
				_this.user_options = {
					toLogin: true,
					showCancel: false
				}
			}
			
		},
		
		onShow() {
			_this.orderIsLock()
			
			// #ifdef H5
			if (_this.cartId && _this.storeInfo) {
				_this.setWxShare()
			}
			// #endif
		},
		onUnload() {
			clearInterval(_this.timer);
		},
		onShareAppMessage() {
			let pageLink = `/pages/shop_new/orderTogether/orderTogether?uid=${_this.userInfo.uid}&nickname=${_this.master}&store_id=${_this.store_id}&cartId=${_this.cartId}&frontColor=${_this.shopFrontColor}&backgroundColor=${_this.shopBackgroundColor}`
			pageLink = common.addShareParam(pageLink)
			return {
				title: shareTxt,
				path: pageLink,
				success: () => {
					_this.showMask = false
				}
			};
			
		},
		methods: {
			orderIsLock () {
				if (!_this.isShowLock && _this.cartInfo && _this.cartInfo.status == 1 && _this.isShare == 0) {
					_this.isShowLock = true
					wx.showModal({
						title: common.changeTxt('提示'),
						content: common.changeTxt('订单已锁定'),
						confirmText: common.changeTxt('解锁订单'),
						showCancel: false,
						success: res => {
							if (res.confirm) {
								wx.showModal({
									title: common.changeTxt('确认解锁'),
									content: common.changeTxt('订单解锁后，您可以继续和好友一起点单'),
									success: res => {
										_this.isShowLock = false
										if (res.confirm) {
											lockingOrder(0);
										} else {
											wx.navigateTo({
												url: `/pages/shop_new/confirmOrder/newCart?store_id=${_this.store_id}&cartId=${_this.cartId}`
											});
										}
									}
								});
							}
						}
					});
				}
			},
			setWxShare() {
				//#ifdef H5
					let url = encodeURIComponent(`/pages/shop_new/orderTogether/orderTogether?nickname=${_this.master}&store_id=${_this.store_id}&cartId=${_this.cartId}`)
					let pageLink = `${common.requestDomain}packapp/${common.wxapp_type}/pages/shop_new/shopDetail/shopDetail?store_id=${_this.store_id}&redirect=${url}`
					let shareWxLink = common.addShareParam(pageLink)
					var shareData = {
						title: shareTxt,
						desc: common.changeTxt('我正在【X1】拼单,有一起的吗？', {X1: this.storeInfo.name}),
						sendFriendLink: shareWxLink,
						share_img: this.storeInfo.image
					}
					common.setWxShare(shareData)
				//#endif
			},
			shareToFriend() {
				// #ifdef H5
				if (common.$checkPlat.checkWeixin()) {
					this.showShareTip = true
				} else {
					uni.showToast({
					    title: common.changeTxt('请在微信环境中打开'),
						icon: 'none',
					    duration: 2000
					});
				}
				// #endif
			},
			getUserInfo(e) {
				if (e.detail.userInfo) {
					initialCart()
				}
			},

			// 取消拼单
			cancel() {
				wx.showModal({
					title: common.changeTxt('提示'),
					content: common.changeTxt('确定取消本次拼单吗？'),
					success: res => {
						if (res.confirm) {
							
							_this.cancelStatus = true
							lockingOrder(6);
							
						}
					}
				});
			},

			// 添加订购人按钮
			openMask() {
				_this.showMask = true
			},

			// 分袋打包按钮
			addNewOrder() {
				clearInterval(_this.timer);
				addNew();
				_this.showMask = false
			},

			// 添加、修改商品
			changeGoods(myindex) {
				clearInterval(_this.timer);
				let orderTogether = {
					store_id: _this.store_id,
					cartId: _this.cartId,
					myindex: myindex
				}
				uni.setStorageSync('orderTogether', orderTogether)
				app.globalData.storeCart = ''
				app.globalData.storeGoods = ''
				shopCommon.initCart().then(() => {
					common.navigateBack()
				})
			},

			// 删除订购人
			deleteGoods(e) {
				wx.showModal({
					title: common.changeTxt('提示'),
					content: common.changeTxt('确定要删除？'),
					success: res => {
						if (res.confirm) {
							deleteItem(e.currentTarget.dataset.id);
						}
					}
				});
			},

			// 选购商品
			selectGoods() {
				clearInterval(_this.timer);
				_this.timer = ''
				addNew('share');
				
			},

			// 和他点一样
			selectSame(index) {
				console.log('点击了和他点一样111', _this.cartInfo, index)
				var productCart = _this.cartInfo.data[index].data;
				clearInterval(_this.timer);
				_this.timer = ''
				addNew('', productCart);
				
			},

			// 去结算
			gotocalculate() {
				if (!this.cartInfo.contains_required_sort) {
					wx.showToast({
						title: common.changeTxt('需要选择【X1】下的商品才可下单哦~', {X1: this.cartInfo.required_sort.sort_name }),
						icon: 'none'
					})
					return
				}
				wx.showModal({
					title: common.changeTxt('确认结算'),
					content: common.changeTxt('结算时订单将被锁定，如需继续点单请返回解锁'),
					success: res => {
						if (res.confirm) {
							lockingOrder(1);
						}
					}
				});
			},
			// 关闭弹窗
			closeMask(e) {
				var name = e.currentTarget.dataset.name
				_this[name] = false
			}
		}
	};
	const initialCart = () => {
		let orderTogether = uni.getStorageSync('orderTogether')
		if (orderTogether && _this.store_id == orderTogether.store_id) {
			_this.cartId = orderTogether.cartId
			_this.personId = orderTogether.myindex
			postCartInfo()
			_this.timer = setInterval(() => {
				postCartInfo();
			}, 5000);
		} else if (_this.isShare == 1) {
			postCartInfo('share')
			_this.timer = setInterval(() => {
				postCartInfo();
			}, 5000);
		} else {
			common.post('Cart&a=initSpellPackage', {store_id: _this.store_id}, (data) => {
				console.log('拼单购物车数据', data)
				if (data) {
					_this.cartId = data.cartid
					_this.personId = data.index
					postCartInfo()
					_this.timer = setInterval(() => {
						postCartInfo();
					}, 5000);
					let orderTogether = {
						store_id: _this.store_id,
						cartId: _this.cartId,
						myindex: data.index
					}
					uni.setStorageSync('orderTogether', orderTogether)
				}
			})
		}
	} 
	const postCartInfo = () => {
		var param = {
			cartid: _this.cartId,
			store_id: _this.store_id,
			myindex: _this.personId,
			from: _this.isShare == 1 && _this.personId != 1 ? 1 : 0,
			noTip: true
		};
		common.post('Shop&a=ajaxAll', param, data => {
			if (data) {
				console.log('轮询数据', data);

				_this.cartInfo = data
				_this.total_money = (data.totalPrice + data.totalPack).toFixed(2)
				
				
				_this.orderIsLock()
				
				if (!_this.storeInfo) {
					_this.storeInfo = data.store
					if (!app.globalData.storeInfo) {
						app.globalData.storeInfo = data.store
					}
					_this.shopFrontColor = data.store.shop_fitment_front_color
					_this.shopBackgroundColor = data.store.shop_fitment_color 
					wx.setNavigationBarColor({
						frontColor: "#" + _this.shopFrontColor,
						backgroundColor: '#' + _this.shopBackgroundColor
					});
				
					if (!app.globalData.storeInfo || (app.globalData.storeInfo && app.globalData.storeInfo.store_id != _this.store_id)) {
						console.log('多人拼单页设置分享222')
						getShopInfo()
					} else {
						console.log('多人拼单页设置分享333')
						_this.storeInfo = app.globalData.storeInfo 
						let pageLink = `${common.requestDomain}packapp/unio2o/#/pages/shop_new/orderTogether/orderTogether?uid=${_this.userInfo.uid}&nickname=${_this.master}&store_id=${_this.store_id}&cartId=${_this.cartId}&frontColor=${_this.shopFrontColor}&backgroundColor=${_this.shopBackgroundColor}`
						console.log('1111pageLink', pageLink)
						_this.setWxShare()
					}
				}
				
				// 判断当前打开分享链接的用户是否已添加过商品
				if (_this.isShare == 1 && _this.personId == 1) {
					for (let i = 0; i < _this.cartInfo.data.length; i++) {
						let item = _this.cartInfo.data[i]
						if (item.uid == _this.userInfo.uid) {
							_this.personId = item.index
							postCartInfo()
							break
						}
					}
				}
				
				if (data.status > 1) {
					clearInterval(_this.timer);
					uni.removeStorageSync('orderTogether')
					if((_this.isShare == 1 && _this.personId == 1) || _this.isShare == 0) {
						shopCommon.initCart().then(() => {
							common.navigateBack()
						})
					}
					return
				}
			}
		});
	};
	const addNew = (status, productCart) => {
		var param = {
			store_id: _this.store_id,
			cartid: _this.cartId,
			from: _this.isShare
		};
		if (productCart) {
			param.productCart = productCart
		}
		common.post('Cart&a=addNew', param, data => {
			if (data) {
				console.log('添加新的订购人', data)
				if (status == 'share') {
					let orderTogether = {
						store_id: _this.store_id,
						cartId: _this.cartId,
						myindex: data.index
					}
					uni.setStorageSync('orderTogether', orderTogether)
					shopCommon.initCart().then(() => {
						common.navigateBack()
					})
				} else {
					_this.personId = data.index
					postCartInfo()
					_this.timer = setInterval(() => {
						postCartInfo();
					}, 5000);
				}
			}
		}, _this, error => {
			wx.showModal({
				title: common.changeTxt('提示'),
				showCancel: false,
				content: error.data.errorMsg
			});
			common.navigateBack()
			_this.cancelStatus = true
			lockingOrder(6);
		});
	};
	const deleteItem = personId => {
		var param = {
			cartid: _this.cartId,
			index: personId,
			store_id: _this.store_id
		};
		common.post('Shop&a=delCart', param, data => {
			wx.showToast({
				title: common.changeTxt('删除成功')
			});
			_this.personId = 1
			uni.removeStorageSync('orderTogether')
			postCartInfo()
		});
	};
	// 锁定拼单
	const lockingOrder = status => {
		var param = {
			cartid: _this.cartId,
			status: status,
			store_id: _this.store_id
		};
		common.post('Shop&a=saveCart', param, data => {
			if (param.status == 0) {
				getCartInfo();
			} else if (param.status == 1) {
				_this.cartInfo.status = 1;
				clearInterval(_this.timer);
				wx.navigateTo({
					url: `/pages/shop_new/confirmOrder/newCart?store_id=${_this.store_id}&cartId=${_this.cartId}`
				});
			} else if (param.status == 6) {
				uni.removeStorageSync('orderTogether')
				shopCommon.initCart().then(() => {
					common.navigateBack()
				})
			}
		});
	};
</script>
<style>
	/* pages/shop_new/orderTogether/orderTogether.css */
	.border-b,
	.border-t {
		position: relative;
	}

	.border-b::after {
		content: '';
		position: absolute;
		bottom: 0;
		left: 0;
		height: 1rpx;
		width: 100%;
		background: #e5e5e5;
		transform: scaleY(0.5);
	}

	.border-t::after {
		content: '';
		position: absolute;
		top: 0;
		left: 0;
		height: 1rpx;
		width: 100%;
		background: #e5e5e5;
		transform: scaleY(0.5);
	}

	button::after {
		border: none;
	}

	page {
		height: 100%;
		background: #fff;
		width: 100%;
		overflow-x: hidden;
	}

	.wrapper {
		position: relative;
		height: 100%;
		width: 100%;
		overflow-x: hidden;
	}

	.header-box {
		background: #06c1ae;
		padding: 15px 10px;
		text-align: center;
		color: #fff;
	}

	.header-box button {
		background: #fff;
		color: #06c1ae;
		font-size: 16px;
		height: 45px;
		border-radius: 5px;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.header-box button .icon-jia1 {
		font-size: 26px;
		margin-right: 5px;
	}

	.header-box button.btn-hover {
		background: #f5f5f5
	}

	.header-box image {
		width: 60px;
		height: 60px;
		border-radius: 4px;
	}

	.header-box .name {
		font-size: 16px;
		margin: 5px 0;
		font-weight: bold;
	}

	.header-box .text {
		font-size: 12px;
		margin-bottom: 10px;
	}

	.tip-box {
		color: #fff;
		font-size: 12px;
		margin-top: 10px;
		display: flex;
		align-items: center;
		justify-content: center;
		text-align: left;
	}

	.tip-box .icon-tishi {
		font-size: 20px;
		margin-right: 5px;
	}

	.null-box {
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		width: 100%;
		text-align: center;
		color: #c4c4c4;
		font-size: 15px;
	}

	.null-box image {
		width: 30%;
		margin-bottom: 30rpx;
	}


	.list-box {
		padding-bottom: 50px;
		position: relative;
	}

	.title-box {
		height: 40px;
		line-height: 40px;
		padding: 0 10px;
		background: #fafafa;
		font-size: 16px;
		color: #999;
	}

	.title-box .icon-dingdan {
		font-size: 18px;
		margin-right: 5px;
	}

	.item {
		padding: 30rpx 10px;
		background: #fff;
	}

	.item.border-b::after {
		left: 10px;
	}

	.my .item.border-b::after {
		height: 0;
	}

	.item .user-box {
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 16px;
		color: #333;
		margin-bottom: 15px;
		height: 21px;
		line-height: 21px;
	}

	.item .user-box.package {
		margin-left: 30px;
	}

	.item .user-box .name-box {
		display: flex;
		align-items: flex-end;
	}

	.item .user-box .num {
		background: #06c1ae;
		width: 21px;
		height: 21px;
		line-height: 21px;
		text-align: center;
		display: inline-block;
		border-radius: 50%;
		color: #fff;
		margin-right: 10px;
		font-size: 14px;
	}

	.item .user-box .avatar {
		width: 21px;
		height: 21px;
		border-radius: 50%;
		margin-right: 10px;
	}

	.item .user-box .name {
		font-weight: bold;
	}

	.item .user-box .icon-bianji {
		color: #bbb;
		margin-left: 5px;
	}

	.item .user-box .tag {
		font-size: 12px;
		margin-left: 10px;
		color: #fff;
		padding: 0 6px;
		border-radius: 3px;
	}

	.item .user-box .weixin {
		background: #ff571a;
	}

	.item .user-box .launch {
		background: #72d53b;
	}

	.item .user-box .my {
		background: #ff98a9;
	}

	.item .user-box .edit-box .btn {
		margin-left: 10px;
		border: 1rpx solid #06c1ae;
		color: #06c1ae;
		border-radius: 3px;
		font-size: 12px;
		padding: 2px 10px;
	}

	.item .user-box .edit-box .del {
		margin-left: 10px;
		border-radius: 3px;
		font-size: 12px;
		padding: 2px 10px;
		color: #999;
		border: 1rpx solid #999;
	}

	.item .goods-box {
		margin-left: 30px;
	}

	.item .goods-box .one {
		margin-top: 10px;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 14px;
		color: #666;
	}

	.item .goods-box .one .name {
		flex: 5;
	}

	.item .goods-box .one .name .desc {
		font-size: 11px;
		color: #999;
	}

	.item .goods-box .one .num {
		color: #bbb;
		flex: 1
	}

	.item .goods-box .one .price {
		flex: 2;
		text-align: right;
	}

	.item .goods-box .one .price .old {
		font-size: 12px;
		text-decoration: line-through;
		color: #999;
		margin-right: 5px;
	}

	.footer {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		display: flex;
	}

	.footer button {
		background: #999;
		border-radius: 0;
		color: #fff;
		font-size: 16px;
		height: 50px;
		line-height: 50px;
	}

	.footer .price {
		background: #393634;
		flex: 2;
		text-align: left;
	}

	.footer .calc {
		background: #06c1ae;
		flex: 1;
	}

	.footer .calc-hover {
		background: #09a595
	}

	.footer.other {
		left: auto;
		right: 10px;
		font-size: 15px;
		color: #333;
		height: 50px;
		line-height: 50px;
		background: #fff;
	}

	.footer.other .fee {
		color: #06c1ae;
		font-size: 20px;
		font-weight: bold;
	}

	.mask {
		background: rgba(0, 0, 0, 0.5);
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
	}

	.mask .content {
		background: #fff;
		width: 85%;
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		border-radius: 5px;
		overflow: hidden;
	}

	.mask .option {
		padding: 20px 15px;
		display: flex;
		align-items: center;
	}

	.mask .option .icon {
		width: 50px;
		height: 50px;
		background: #ff571a;
		border-radius: 50%;
		color: #fff;
		font-size: 16px;
		line-height: 50px;
		text-align: center;
		margin-right: 10px;
	}

	.mask .option .icon .iconfont {
		font-size: 24px;
	}

	.mask .option .desc {
		font-size: 12px;
		color: #999;
		margin-top: 3px;
	}

	.mask .option .icon.weixin {
		background: #45c144;
	}

	.mask button.option {
		text-align: left;
		line-height: 1.3;
		background: #fff;
	}

	.mask .content.locking {
		width: 60%;
		color: #333;
		padding: 10px;
	}

	.mask .content.locking .title {
		text-align: center;
	}

	.mask .content.locking .desc {
		padding: 10px;
		font-size: 15px;
		color: #999;
	}

	.mask .share-img {
		position: absolute;
		right: 0;
	}

	.cancel-mask {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background: rgba(255, 255, 255, .7);
		z-index: 9;
	}
</style>
